package oop.day09vis.homework;

/**
 * 这是一个电影售票类
 * 打折，18岁以下半价，18以上全票
 */
public class MovieTicket {
    private String name;
    private int age;
    private int price;

    MovieTicket(){}
    MovieTicket(String name, int age) {
        this.name = name;
        this.age = age;

        /*if (age<18){
            this.price = 20;
        }else {
            this.price = 40;
        }*/
        this.price = age >= 18 ? 40:20;

    }
    public void setPrice(int price) {
        this.price = age >= 18 ? price :price/2;
    }
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public int getPrice() {
        return price;
    }



    public void printInfo(){
        System.out.println(this.name+"\t"+this.age+"\t"+this.price);
    }

}
